package org.xg.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.xg.dao.AuthorityDao;
import org.xg.dao.Role2AuthorityDao;
import org.xg.dao.User2AuthorityDao;
import org.xg.dao.User2RoleDao;
import org.xg.domain.AuthorityVO;
import org.xg.domain.RoleVO;

import com.googlecode.genericdao.search.ISearch;
import com.googlecode.genericdao.search.Search;

@Service
@Transactional
public class AuthorityBS {

	@Resource
	private AuthorityDao authDao;
	
	@Resource
	private User2AuthorityDao user2authDao;
	
	@Resource
	private Role2AuthorityDao role2authDao;
	
	public List<AuthorityVO> search( ISearch s ){
		return authDao.search(s);
	}
	
	/**
	 * 根据用户名获取权限
	 * @param username
	 * @return
	 */
	public List<AuthorityVO> findAuthsByUsername(String username){
		return user2authDao.findAuthsByUsername(username);
	}
	
	/**
	 * 根据用户id获取权限
	 * @param id
	 * @return
	 */
	public List<AuthorityVO> findAuthsByUserid(String id){
		return user2authDao.findAuthsByUserid(id);
	}

	/**
	 * 查找角色对应的权限
	 * @param id
	 * @return
	 */
	public List<AuthorityVO> findAuthsByRoleid(String id) {
		return role2authDao.findAuthsByRoleid(id);
	}
	
	
	
}
